import java.util.ArrayList;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 86156
 * Date: 2023-04-09
 * Time: 22:11
 */

// 根据id返回 true或者false
public class userTest {
    public static void main(String[] args) {
        ArrayList<user> list = new ArrayList<>();
        user user1 = new user(1,"zhangsan","1234");
        user user2 = new user(2,"lisi","1234");
        user user3 = new user(3,"wangwu","1234");
        list.add(user1);
        list.add(user2);
        list.add(user3);

        boolean flag = select(list,2);
        System.out.println(flag);

    }

    public static boolean select(ArrayList<user> list,int id){
        for (int i = 0; i < list.size(); i++) {
            if(list.get(i).getId() == id){
                return true;
            }
        }return false;
    }
}
